home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Archiv / Install_3.3.lha / Install_3.3 / ARexx / Install_GetID.dopus5 < prev    next >
Text File  |  1997-05-09  |  5KB  |  189 lines

  1. /* $VER: Install_GetID.dopus5 3.1 (09.05.97) © Frédéric Steinfels
  2. */
  3.  
  4. signal on BREAK_C
  5. signal on BREAK_D
  6. signal on BREAK_E
  7. signal on BREAK_F
  8. signal on HALT
  9. signal on IOERR
  10. signal on SYNTAX
  11. signal on FAILURE
  12. options failat 21
  13. options results
  14. parse arg arguments
  15. ProgramName = "Install_GetID.dopus5";
  16. ArgsTemplate = "PORT/A,MNPORT/A,MYPORT/A,MYID/A,WRITECOM/S,LPATH/A"
  17. lf='0a'x
  18. if strip(arguments) = '?' then do
  19.     Call WriteCh(STDOUT, ArgsTemplate || ': ')
  20. pull arguments
  21. end; else nop
  22. if ~ReadArgs(arguments,ArgsTemplate) then do
  23.     say Fault(RC,ProgramName)
  24.      exit 10
  25. end; else nop
  26. drop arguments
  27. catalog=opencatalog('Install.dopus5.catalog','english',0)
  28.  
  29. address value PORT
  30.  
  31. inlocpr='DOpus5:System/Install_Locale.prefs'
  32. if ~open(lp,inlocpr,'READ') then do
  33.     dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(15,'Unable to open') inlocpr || '"' GetCatStr(0,'Abort')
  34.     Call CleanUP
  35.     exit
  36. end
  37. junk=readln(lp)
  38. month=1
  39. do while month < 13
  40.     cnt=0
  41.     do while cnt<9
  42.         d.month.cnt=readln(lp)
  43.         cnt=cnt+1
  44.     end
  45.     month=month+1
  46. end
  47. d.tr=readln(lp)
  48. Call Close(lp)
  49.  
  50.  
  51. MYPORTH=openport(MYPORT)
  52.  
  53. do until CMD='0'
  54.     call waitpkt(MYPORT)
  55.     Packet=getpkt(MYPORT)
  56.     if Packet ~= null() then do
  57.         ln = getarg(Packet,0)
  58.         ID=substr(ln,1,1)
  59.         CMD=substr(ln,2,1)
  60.         ARG=substr(ln,3)
  61.         call CheckArg
  62.         IF ID=0 & CMD=1 THEN DO
  63.             vdate=0
  64.             q=0
  65.             com=''
  66.             parse var arg path '0a'x name '0a'x numf '0a'x fdate '0a'x note
  67.             file=makepath(makepath(lpath,path),name)
  68.             if open(test,file,'READ') then do
  69.                 Call Close(test)
  70.                 com=crc32(file)
  71.                 com=com || copies('0',8-length(d2x(fdate))) || d2x(fdate)
  72.                 ADDRESS COMMAND 'Failat 21' || lf || 'version >T:VER' || MYPORT 'FULL FILE "' || file || '"' || lf || 'If Warn' || lf || 'Delete T:VER' || MYPORT || lf || 'EndIf'
  73.                 if open(f,'T:VER'||MYPORT,'READ') then do
  74.                     do while ~EOF(f)
  75.                         com=com readln(f)
  76.                     end
  77.                     Call Close(f)
  78.                     com=TRANSLATE(com,' ','a0'x)
  79.                     rest=substr(com,10)
  80.                     year=0
  81.                     do while year=0 & POS('(',rest)<POS(')',rest) & POS('(',rest)>0
  82.                         parse var rest . '(' tdate ')' rest
  83.                         bdate=tdate
  84.                         month=1
  85.                         do while month < 13 & year=0
  86.                             if length(tdate)=d.month.0 then Call ParseLocDate
  87.                             month=month+1
  88.                         end
  89.                         month=month-1
  90.                     end
  91.                     if year~=0 then do
  92.                         day=strip(day,'L')
  93.                         day=copies('0',2-length(day)) || day
  94.                         month=copies('0',2-length(month)) || month
  95.                         tdate=day || '.' || month || '.' || year
  96.                         vdate=DATE('i',year || month || day,'s')
  97.                         q=pos(bdate,com)
  98.                         l=length(bdate)
  99.                         com=delstr(com,q,l)
  100.                         com=insert(tdate,com,q-1)
  101.                     end
  102.                 end
  103.                 do while POS('  ',com) ~= 0
  104.                     com=DELSTR(com,POS('  ',com),1)
  105.                 end
  106.                 com=strip(com,'T')
  107.                 if note~='' then com = com || '¸' note
  108.                 if length(com)>79 then com=left(com,79)
  109.                 if WRITECOM=1 then do
  110.                     rv=setcomment(file,com)
  111.                 end
  112.             end
  113.             dopus send MNPORT MYID || 1 || name || lf || numf || lf || com
  114.         end
  115.     end
  116. end    
  117.         
  118. Call CleanUP
  119. exit
  120.  
  121.  
  122. ParseLocDate:
  123. if d.month.1~=0 then if substr(tdate,d.month.1,1)~=d.tr then return
  124. if d.month.2~=0 then if substr(tdate,d.month.2,1)~=d.tr then return
  125. if SUBSTR(tdate,d.month.6,d.month.7)~=d.month.8 then return
  126. day=substr(tdate,d.month.3,2)
  127. year=substr(tdate,d.month.4,2)+1900
  128. if year<78 then year=year+100
  129. return
  130.  
  131.  
  132. CheckArg:
  133. IF DATATYPE(ID)~='NUM' | DATATYPE(CMD)~='NUM' THEN Call CheckArgFail
  134. IF ID~=0 THEN Call CheckArgFail
  135. IF CMD>1 THEN Call CheckArgFail
  136. RETURN
  137.  
  138.  
  139. CheckArgFail:
  140. address value PORT
  141. dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(52,'Invalid packet received') || lf || 'ID=' || ID || lf || 'CMD=' || CMD || lf || 'ARG=' || ARG || '"' GetCatStr(0,'Abort')
  142. Call CleanUP
  143. exit
  144.  
  145.  
  146.  
  147.  
  148.  
  149. ERROR:
  150. HALT:
  151. IOERR:
  152. SYNTAX:
  153. IF RC ~= 0 THEN DO
  154.  line=sigl
  155.  text=errortext(rc)
  156.  dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || text || lf || GetCatStr(19,'Line') line || '"' GetCatStr(0,'Abort')
  157. END
  158. else do
  159.  dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || '"' GetCatStr(0,'Abort')
  160. end
  161. BREAK_C:
  162. BREAK_D:
  163. BREAK_E:
  164. BREAK_F:
  165. Call CleanUP
  166. exit
  167.  
  168.  
  169. CleanUp:
  170. dopus send MNPORT MYID || 0
  171. if POS(MYPORT,SHOW('p'))~=0 then do
  172.     Call FORBID()
  173.     Call ClosePort(MYPORTH)
  174.     Call PERMIT()
  175. end
  176. Call CloseCatalog(catalog)
  177. return
  178.  
  179.  
  180. getcatstr: /* Thank you for this procedure, Edmund */
  181. parse arg msgno,msgstring
  182. if catalog~=0 then
  183.    msgstring=getcatalogstr(catalog,msgno,msgstring)
  184. do i=3 to arg()
  185.    parse var msgstring fore '%s' aft
  186.    msgstring=fore||arg(i)||aft
  187.    end
  188. return msgstring
  189.